<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>主要完成人详细信息</title>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript"
	src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/validate/irisvalidator.js"></script>

<style type="text/css">
.input_width {
	width: 130px
}

.select_width {
	width: 143px
}

.table_td td {
	border: 0
}

.long_input {
	width: 642px
}

.selectWidth4 {
	width: 636px;
}
</style>
<script type="text/javascript">
	var type = "${param.type}";
	var parentTable = parent.$("#" + "${param.parentTab}"); //父页面的表格
	var selectRadio = $(); //父页面选中的单选框
	var selectTr = $(); //父页面选中的行

	if (type == "edit") {
		selectRadio = parentTable.find(":radio:checked");
		selectTr = selectRadio.parents("tr");
	}

	$(function() {

		$("#fragment-tab1 :text,#fragment-tab1 [type='date']").addClass(
				"input_width");
		$("#fragment-tab1 select").addClass("select_width");
		$(".inputSelectButton").hide();
		$("#prof_title_name_tree_img").hide();

		initControl();

		var submitpsn = selectTr.find("[name$='submit_psn']");//标示是否是申报人

		if (type == "edit") {

			$("input:not(:radio:button),textarea").each(function() {

				var id = $(this).attr("name");
				if (id == null || id == "")
					return true;

				var parentObj = selectTr.find("[name$='/" + id + "']");
				var value = "";

				if (parentObj.is("span"))
					value = $.trim(parentObj.text());
				else
					value = parentObj.val();

				//var reg = new RegExp("position_2$");

				$(this).val(value);
			});

			$(":radio").each(function() {//初始化radio框
				var name = $(this).attr("name");

				var value = $("[name='" + name + "_value']").val();
				if ($(this).val() == value)
					$(this).attr("checked", true);

			});
			tree();
			$("#submit_psn_note").show();

			$("input,select").each(

					function() {
						if (!$(this).attr("class")
								|| $(this).attr("class").indexOf(
										"notdisabled") == -1)
							$(this).attr("disabled", true);

						//$("img").css("display", "none");
						//$("a").css("display", "none");

					});

			for (var i = 1; i < 17; i++) {
				$("#s" + i).remove();
			}


		}

		$("#org").css("width", "82%");
		function savePsn() {

			validate($("#fragment-tab1"), "");
			if (!valResult()) {
				irisValShowMsg($("#savePsn"));
				return false;
			}

			//添加新行
			if (type == "add") {
				addNewRowDeal(parentTable);
			}

			$("textarea").each(
					function() {
						var val = $(this).val();
						val = val.replace(/&/g, "&amp;").replace(/</g, "&lt;")
								.replace(/>/g, "&gt;").replace(/\n/g, "<br/>")
								.replace(/\s/g, "&nbsp;").replace(/"/g,
										"&quot;");
						$("input[name='" + $(this).attr('name') + "_hidden']")
								.val(val);
					});

			$("input:not(:radio:button),textarea").each(
					function() {

						var id = $(this).attr("name");

						var parentObj = null;

						if (id == null || id == "")
							return true;

						//获得父页面的对象
						if (type == "add") {
							parentObj = parentTable.find("tr:last-child").find(
									"[name$='/" + id + "']");
						} else if (type == "edit") {
							parentObj = selectTr.find("[name$='/" + id + "']");

						}

						if (parentObj != null) {
							
							//alert(parentObj.attr("name")+"   "+$(this).attr("name")+"   "+$(this).val());

							if (parentObj.is("span")) {

								parentObj.text($(this).val()); //将值写回父页面
							} else {
								parentObj.val($(this).val());
							}
						}

					});

			$(".wBox_popup").hide();
			alert("保存成功");
			window.setTimeout("parent.tb_remove()", 1000);

		}

		$("#savePsn").click(function() {
			setTimeout(savePsn, 100);
		});

		checkCardCode();
	});

	function tree() {
		var prof_title_name = $("#prof_title_name").val();
		$("#prof_title").val(prof_title_name);

	}

	function loadAjaxSelect(selectId, url, params, varParm) {
		$.ajax({
			url : url,
			type : 'post',
			dataType : 'json',
			data : params,
			success : function(data) {

				for (var i = 0; i < data.length; i++) {
					var value = data[i].id;
					var text = data[i].name;
					$("#" + selectId).append(
							"<option value='"+value+"'>" + text + "</option>");

				}
				if (type == "edit") {//如果是修改，才需要初始化select框的值
					var selectValue = $("[name='" + selectId + "_value']")
							.val();
					$("#" + selectId + " option").each(function(i, obj) {
						if ($(obj).val() == selectValue) {
							setTimeout(function() {
								$(obj).attr("selected", true);

								// 如果父页面没有card_type_name，则要在弹出页面中异步获取下拉框时，将证件类型写到隐藏表单中
								if (selectId == "card_type") {
									$("#card_type_name").val($(obj).text());
								}
							}, 1);
						}
					});
				}

				//setDegree();
			}
		});
	}
</script>
<script type="text/javascript">
	function initTreeValueExt(treeId, treeNode) {

		if (!(treeNode && (treeNode.level > 0 || !treeNode.isParent))) {
			scmWarn($("#" + treeId).attr("label")
					+ messageTip.researchAreaInvalidDisciplineCode);
			if (treeNode.level == 0) {
				$("#" + treeId).val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_code'],[id$='" + treeId
								+ "_code']").val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_value'],[id$='" + treeId
								+ "_value']").val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_name'],[id$='" + treeId
								+ "_name']").val("");
			}

			return false;
		}

		var str = treeNode.name;
		var obj = treeNode.parentNode;
		while (obj != null) {

			str = obj.name + "-" + str;
			obj = obj.parentNode;

		}

		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_code'],[id$='" + treeId + "_code']")
				.val(treeNode.id);
		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_value'],[id$='" + treeId + "_value']")
				.val(treeNode.id);
		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_name'],[id$='" + treeId + "_name']")
				.val(str);

	}

	function checkCardCode() {
		var type = $("#card_type_value").val();

		if (type == 1) {
			$("#card_code").addClass("idCard");
			$("#card_code").attr("label", "身份证");
		} else {
			$("#card_code").removeClass("idCard");
			$("#card_code").attr("label", "证件号码");
		}

	}
</script>
</head>
<body>

	<div id="tabnav">
		<ul>
			<li class="down" id="tab1" onclick="changeTab(this.id)"><a
				href="###"><span>个人信息</span></a></li>
		</ul>
	</div>

	<div class="tab_box" id="fragment-tab1">
		<table class="t_css" width="100%" border="0" cellpadding="0"
			label="个人信息" cellspacing="1">
			<col style="width: 20%">
			<col style="width: 30%">
			<col style="width: 20%">
			<col style="width: 30%">
			<tr>
				<td nowrap align="right"><span id="s1" class="color_red">*</span>姓名：</td>
				<td width="350px">
					<input id="zh_name" name="zh_name" label="姓名" type="text" class="input_text required maxlength:25"  value="" maxlength="25" /> 
				</td>
				<td align="right"><span id="s2" class="color_red">*</span> 性别：</td>
				<td><input type="radio" id="gender_1" name="gender" label="男"
					value="M" class="do" />男 &nbsp;&nbsp;&nbsp;&nbsp; <input
					type="radio" id="gender_2" name="gender" label="女" value="F"
					class="do" />女
					 <input type="hidden" name="gender_value" label="性别" class="required" value="" /> 
					 <input type="hidden" name="gender_name" value="" /></td>
			</tr>
			<tr>
				<td align="right">出生地：</td>
				<td>
					<input type="text" id="birth_area" name="birth_area" maxlength="40"   class="  required" label="出生地"/>
				</td>

				<td align="right">民族：</td>
				<td>
					<cpt:select id="ethnicity" key="nation" onChange="initControlValue(this.id)" cacheable="false"></cpt:select>
					<input type="hidden" name="ethnicity_value" value="" label="民族" class="required"> 
					<input type="hidden"  name="ethnicity_name" value="">
				</td>
			</tr>
			<tr>
				<td align='right'><span id="s4" class="color_red">*</span>出生日期：</td>
				<td>
					<cpt:date id="birthday" value="" className="required beforeToday" label="出生日期" name="birthday"></cpt:date>
					<input type='hidden' name='age' id='age' value="" />
				</td>
				<td align="right">党派：</td>
				<td>
					<cpt:select id="party" key="party" onChange="initControlValue(this.id)" cacheable="false" className=" "></cpt:select>
					<input type="hidden" name="party_value" value="" label="党派" class="required"> 
					<input type="hidden"  name="party_name" value="">
				</td>
				<%-- <td align="right">何国华侨：</td>
				<td>
					<cpt:select id="overseas" key="country" name="overseas" className="required " label="何国华侨" onChange="initControlValue(this.id)"></cpt:select>
					<input type="hidden" name="overseas_value" value="" /> 
					<input type="hidden" name="overseas_name" value="" />
				</td> --%>
			</tr>
			<tr>
				<%-- <td align="right"><span id="s16" class="color_red">*</span>证件类型：</td>
				<td><cpt:select id="card_type" key="id_type" name="card_type" className="required " label="证件类型" onChange="initControlValue(this.id);checkCardCode();"></cpt:select>
					<input type="hidden" id="card_type_value" name="card_type_value" value="" /> 
					<input type="hidden" id="card_type_name" name="card_type_name" value="" />
				</td> --%>
				<td align="right"><span id="s5" class="color_red">*</span>身份证号：</td>
				<td>
					<input type="text" name="card_code" id="card_code" class="input_text required" maxlength="30" />
				</td>
				<td align="right">是否是院士：</td>
				<td>
					<cpt:select id="isyuansi" key="isornoys" onChange="initControlValue(this.id)"  className=" " cacheable="false"></cpt:select>
					<input type="hidden" name="isyuansi_value" value="" label="是否是院士" class="required"> 
					<input type="hidden"  name="isyuansi_name" value="">
				</td>
			</tr>
			<tr>
				<td align="right"><span id="s8" class="color_red">*</span>工作单位：</td>
				<td><input type="text" name="org_name" maxlength="34" class="required" label="工作单位" /></td>
				<td align="right"><span id="s7" class="color_red">*</span>联系电话：</td>
				<td>
					<input type="text" name="tel_work" maxlength="50" class="required" label="联系电话" />
				</td>
			</tr>
			<tr>
				<td align="right"><span id="s14" class="color_red">*</span>通讯地址：</td>
				<td>
					<input type="text" style="width: 82%" name="address" maxlength="34" class="required" label="通讯地址" />
				</td>
				<td align="right">邮政编码：</td>
				<td>
					<input type="text" name="post_code" onfocus="InitInput.setInt(this,6,0,0)" maxlength="6" class="required" label="邮政编码" />
				</td>
			</tr>
			<tr>
				<td align="right">家庭住址：</td>
				<td align="left">
					<input type="text" name="home_address" maxlength="34" class="required" style="width: 82%" label="家庭住址" />
				</td>
				<td align="right">手机号码：</td>
				<td><input type="text" name="mobile" maxlength="20" class="required" label="手机号码" /></td>
			</tr>
			<tr>
				<td align="right"><span id="s6" class="color_red">*</span>电子邮箱：</td>
				<td>
					<input type="text" name="email" maxlength="20" class="required email" label="电子邮箱" />
				</td>
			</tr>
			<tr>
				<td align="right"><span id="s15" class="color_red">*</span>毕业学校：</td>
				<td>
					<input type="text" name="graduate_college" maxlength="24" class="required " label="毕业学校" />
				</td>
				<td align='right'>毕业时间：</td>
				<td>
					<cpt:date id="graduation" value="" className="required date input_text" label="毕业时间" name="graduation_date"></cpt:date>
					<input type='hidden' name='graduation_time' id='graduation_time' value="" />
				</td>
			</tr>
			<tr>
				<td align="right"><span id="s9" class="color_red">*</span>最高学历：</td>
				<td>
					<cpt:select id="educate" key="educate" onChange="initControlValue(this.id);"></cpt:select>
					<input type="hidden" name="educate_value" class="required" value="" label="文化程度">
					<input type="hidden" name="educate_name" value="">
				</td>
				<td align="right"><span id="s10" class="color_red">*</span>最高学位：</td>
				<td>
					<cpt:select id="degree" key="degree" onChange="initControlValue(this.id);"></cpt:select>
					<input type="hidden" name="degree_value" value="" label="最高学位" class="required">
					<input type="hidden" name="degree_name" value="">
				</td>
			</tr>
			<tr>
				<td align="right">行政职务：</td>
				<td><input type="text" label="职务" name="position_2" id="position_2" class="required" maxlength="24" /></td>
				<td align="right">技术职称：</td>
				<td>
					<cpt:tree key="prof_title" cacheable="false" className="required " readonly="true" value="" id="prof_title_name" showPattern="all" shieldPattern="-1" onClick="initTreeValueExt"   label="技术职称" />
					<input type="hidden" name="prof_title_value" value="" label="技术职称"  >
				</td>
			</tr>
			<tr>
				<td align="right">专业专长：</td>
				<td colspan="3">
					<input type="text" style="width: 82%"  label="专业" name="major" class="required" maxlength="70" />
				</td>
			</tr>
			<tr>
				<td align="right">曾获奖励及荣誉：
				</td>
				<td align="left" colspan="3">
					<input type="text" style="width: 82%"  label="曾获奖励及荣誉" name="wcr_honour" class="  required" maxlength="70" />
				</td>
			</tr>
			<tr>
				<td align="right">参加本项目开始时间：</td>
				<td align="left">
					<cpt:date label="参加本项目开始时间" id="current_prj_startdate" size="14"
						className="date input_text required dateCompare:current_prj_enddate"
						name="prj_startdate" value="${current_prj_startdate}">
					</cpt:date>
				</td>
				<td align="right">参加本项目结束时间：</td>
				<td align="left">
					<cpt:date id="current_prj_enddate" value="${current_prj_enddate}" size="14" className="date input_text  required " 
					name="prj_enddate" label="参加本项目结束时间"></cpt:date>
				</td>
			</tr>
			<tr>
				<td align="right">创造性贡献：<br />（限400字）</td>
				<td align="left" colspan="3">
					<textarea rows="7" style="width: 88%;" name="wcr_creativity_contribute"
						class="input_textarea required maxlength:400" label="创造性贡献" disabled></textarea>
					<input type="hidden" name="wcr_creativity_contribute_hidden" /></td>
			</tr>
		</table>
	</div>

</body>
</html>

<script>
</script>
